RETRIEVE email details- java

To retrieve a detailed log of your messaging history, use the following code:

import com.google.gson.FieldNamingPolicy;

import com.google.gson.Gson;

import com.google.gson.GsonBuilder;

import com.google.gson.JsonArray;

import com.google.gson.JsonObject;

import com.google.gson.JsonPrimitive;

 

import java.io.BufferedReader;

import java.io.DataOutputStream;

import java.io.InputStreamReader;

import java.net.HttpURLConnection;

import java.net.URL;

 

public class Default {

        public static String apiKey = "ApiKey";

 

        public static void main(String[] args) throws Exception {

               try {

                       getEmailByIds();

               }

               catch(Exception ex) {

                       System.out.println(ex.getMessage());

               }

        }

 

        private static void getEmailByIds() throws Exception {

 

               String url = "https://messagingapis.paylite.net/api/messagingdata/GetEmailByIds";

 

               Gson gson = new GsonBuilder().setPrettyPrinting().serializeNulls().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).create();

 

               JsonArray emailIds = new JsonArray();

               emailIds.add(new JsonPrimitive("11d26b81-ad9e-456c-8448-f7ba7e5f6323"));

               //emailIds.add(new JsonPrimitive("ad9b39d8-69aa-4f2e-89d3-5669819c9f77"));

 

               JsonObject jsonData = new JsonObject();

               jsonData.addProperty("ApiKey", apiKey);

               jsonData.add("EmailIds", emailIds);

 

               String postJsonData = gson.toJson(jsonData);

               System.out.println(postJsonData);

 

               postRequest(url, postJsonData);

        }         

}